#include "svgwidget.h"

// 鼠标滚轮事件，滚轮每滚动1°，相当于移动8°，常见的滚轮鼠标波动一下滚动的角度为15°，相当于移动了15*8=120°

SvgWidget::SvgWidget()
{
    render =renderer();
}

void SvgWidget::wheelEvent(QWheelEvent *e)
{
    const double diff=0.1;

    // 获取绘制区的尺寸
    QSize size =render->defaultSize();
    int width =size.width();
    int height =size.height();

    if(e->delta()>0) // >0表示鼠标干滚轮向前（远离用户的方向）滚动，<=表示向后滚动
    {
        width =int(this->width()+this->width()*diff);
        height =int(this->height()+this->height()*diff);
    }
    else
    {
        width =int(this->width()-this->width()*diff);
        height =int(this->height()-this->height()*diff);
    }
    resize(width,height);
}
